package com.adou.d5.demo;

public class MovieOperator {
    private Movie[] movies;

    public MovieOperator(Movie[] movies){
        this.movies = movies;
    }

    // 展示所以全部电影信息
    public void printAllMovie(){
        System.out.println("//////////系统电影信息//////////-");
        for (int i = 0; i < movies.length; i++) {
            Movie movie = movies[i];
            System.out.println("编号：" + movie.getId());
            System.out.println("名称：" + movie.getName());
            System.out.println("价格：" + movie.getPrice());
            System.out.println("//////////////////////////");
        }
    }

    // 根据电影编号id查询电影信息
    public void getMovieById(int id){
        for (int i = 0; i < movies.length; i++) {
            Movie movie = movies[i];
            if(movie.getId() == id) {
                System.out.println("该电影信息如下");
                System.out.println("编号：" + movie.getId());
                System.out.println("名称：" + movie.getName());
                System.out.println("价格：" + movie.getPrice());
                System.out.println("//////////////////////////");
                return;
            }
        }
        System.out.println("没有该电影信息");
    }


}
